
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1, minimum-scale=1, user-scalable=no">
<title>淘小鸭</title>
<script type="text/javascript" src="/js/jquery.min.js"></script>
<meta name="keywords" content="淘小鸭">
<meta name="description" content="淘小鸭">
<style>
blockquote, body, dd, dir, dl, fieldset, figure, form, h1, h2, h3, h4, h5, h6, hr, input, legend, menu, ol, optgroup, p, pre, tbody, td, textarea, tfoot, th, thead, ul {
	margin: 0;
	padding: 0
}
ol, ul {
	list-style-type: none;
	list-style-image: none
}
body, button, input, select, textarea {
	-ms-text-autospace: ideograph-alpha ideograph-numeric ideograph-parenthesis;
	text-autospace: ideograph-alpha ideograph-numeric ideograph-parenthesis
}
h1, h2, h3, h4, h5, h6 {
	font-weight: 400
}

* {
	-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

body {
	background: #F6F5F7;
}
.beatHeader {
	background: #494A4D;
	height: 50px;
	width: 100%;
	position: relative;
	z-index: 1;
	overflow: hidden;
}

.beatMain {
	position: relative;
	z-index: 2;
	padding: 0 16px;
}

.beatMain .imgContainer {
	padding: 0 16px;
	margin-top: 14px;
}

.beatMain .imgContainer img {
	width: 100%;
	height: auto;
	box-shadow: 0px 3px 12px rgba(21, 0, 71, 0.16);
}

.beatMain .moonTitleContainer {
	font-size: 14px;
	color: rgba(0, 0, 0, 0.4);
	margin-bottom: 16px;
}

.beatMain .moonTitleContainer span {
	color: #FF5500;
	margin-right: 16px;
}

.beatMain .itemContent {
	font-size: 14px;
	color: rgba(0, 0, 0, 0.80);
	line-height: 21px;
	text-align: left;
	margin-bottom: 10px;
}

.beatMain .itemPrice {
	font-family: STHeitiSC-Light;
	font-size: 16px;
	color: #FF5500;
	line-height: 16.5px;
	text-align: right;
	margin-bottom: 10px;
}



.beatMain .itemTips {
	font-size: 12px;
	color: rgba(0,0,0,.4);
	text-align: center;
}

.beatWord {
	text-align: center;
}

.beatWord fieldset {
	padding: 0.8em;
	margin: 0 2px;
	border: 1px dashed #f54d23;
	background: #fff;
}

.beatWord fieldset legend {
	background: #f54d23;
	border: none;
	font-size: 0.8rem;
	line-height: 20px;
	color: #fff;
	padding: 0 4px;
}

.beatWord button {
	border: none;
	font-size: 16px;
	padding: 6px 15px;
	background: #f60;
	display: inline-block;
	margin: 10px auto;
	border-radius: 16px;
	color: #fff;
}
</style>
</head>
<body>
<div class="beatMain">
	<div class="imgContainer">
		<img id="img" src="" alt="">
	</div>
	<p class="itemContent">
		<strong class="itemPrice"></strong>
		<div id="item_title" style="font-weight: 700;font-size: 14px;margin-bottom: 5px;"></div>
	</p>
	<div class="beatWord">
		<fieldset>
			<legend id="copy_tip">长按框内>全选>复制>打开手淘</legend>
			<p id="itemWord" class="itemWord" style="font-size: 12px;">复制框内整段文字，打开「手淘」即可「领取优惠券」并购买<span id="taokey"></span></p>
		</fieldset>
		<button id="copy" type="button" data-clipboard-text="" class="itemCopy" style="display:none;">一键复制</button>
		<a id="coupons" href="" style="background: #00a1ff;border: none;font-size: 16px;padding: 6px 15px;display:none;margin: 10px 4px 10px 4px;border-radius: 16px;color: #fff;text-decoration: none;">电脑链接</a>
	</div>
	<div style="font-size: 19px;text-align:center;padding-top:10px;">①点一键复制后回到淘宝</div>
	<div style="font-size: 19px;text-align:center;padding-top:10px;">②弹出商品框后点击打开</div>
	<div style="font-size: 19px;text-align:center;padding-top:10px;">③购买后会收到红包信息</div>
</div>

<script type="text/javascript" src="js/clipboard.min.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>

<script>
function Base64() {
 
    // private property
    _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
 
    // public method for encoding
    this.encode = function (input) {
        var output = "";
        var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
        var i = 0;
        input = _utf8_encode(input);
        while (i < input.length) {
            chr1 = input.charCodeAt(i++);
            chr2 = input.charCodeAt(i++);
            chr3 = input.charCodeAt(i++);
            enc1 = chr1 >> 2;
            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
            enc4 = chr3 & 63;
            if (isNaN(chr2)) {
                enc3 = enc4 = 64;
            } else if (isNaN(chr3)) {
                enc4 = 64;
            }
            output = output +
            _keyStr.charAt(enc1) + _keyStr.charAt(enc2) +
            _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
        }
        return output;
    }
 
    // public method for decoding
    this.decode = function (input) {
        var output = "";
        var chr1, chr2, chr3;
        var enc1, enc2, enc3, enc4;
        var i = 0;
        input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
        while (i < input.length) {
            enc1 = _keyStr.indexOf(input.charAt(i++));
            enc2 = _keyStr.indexOf(input.charAt(i++));
            enc3 = _keyStr.indexOf(input.charAt(i++));
            enc4 = _keyStr.indexOf(input.charAt(i++));
            chr1 = (enc1 << 2) | (enc2 >> 4);
            chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
            chr3 = ((enc3 & 3) << 6) | enc4;
            output = output + String.fromCharCode(chr1);
            if (enc3 != 64) {
                output = output + String.fromCharCode(chr2);
            }
            if (enc4 != 64) {
                output = output + String.fromCharCode(chr3);
            }
        }
        output = _utf8_decode(output);
        return output;
    }
 
    // private method for UTF-8 encoding
    _utf8_encode = function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";
        for (var n = 0; n < string.length; n++) {
            var c = string.charCodeAt(n);
            if (c < 128) {
                utftext += String.fromCharCode(c);
            } else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            } else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }
 
        }
        return utftext;
    }
 
    // private method for UTF-8 decoding
    _utf8_decode = function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;
        while ( i < utftext.length ) {
            c = utftext.charCodeAt(i);
            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            } else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            } else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }
        }
        return string;
    }
}
function GetQueryString(name)
{
     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
     var r = window.location.search.substr(1).match(reg);
     if(r!=null)return  unescape(r[2]); return null;
}
$(function(){
	var b = new Base64();
	var tbk=b.decode(GetQueryString("taowords"));
	var img=b.decode(GetQueryString("pic"));
	$("#img").attr("src",img);
	$("#copy").attr("data-clipboard-text",tbk);
	$("#taokey").text(tbk);
})

//复制文本
var clipboard = new Clipboard('.itemCopy');
clipboard.on('success',
function(e) {
	if (e.trigger.disabled == false || e.trigger.disabled == undefined) {
		e.trigger.innerHTML = "复制成功，打开淘宝会自动弹出口令";
		e.trigger.style.backgroundColor = "#9ED29E";
		e.trigger.style.borderColor = "#9ED29E";
		//e.clearSelection();
		e.trigger.disabled = true;
		//2秒后按钮恢复原状
		setTimeout(function() {
			e.trigger.innerHTML = "一键复制";
			e.trigger.style.backgroundColor = "#f54d23";
			e.trigger.style.borderColor = "#f54d23";
			e.trigger.disabled = false;
		},
		2000);
	}
});

clipboard.on('error',
function(e) {
	e.trigger.innerHTML = "复制失败";
	e.trigger.style.backgroundColor = "#8f8f8f";
	e.trigger.style.borderColor = "#8f8f8f";
});

$(function() {
	//UA判断
	var isShow = 0; //控制是否显示一键复制按钮
	var ua = navigator.userAgent.toLowerCase();
	if (ua.match(/iphone/i) == "iphone" || ua.match(/ipad/i) == "ipad") {
		$('#copy_tip').text("长按框内 > 拷贝 > 打开手淘");
		var iphoneInfo = ua.match(/iphone os (\d{1,})/i);
		var iosVersion = iphoneInfo[1];
		if (iosVersion >= 10 || ua.match(/ipad/i) == 'ipad') {
			$('.itemCopy').show();
		}
	} else {
		$('.itemCopy').show();
	}
	//自动选中
	var beat = document.querySelector('.beatWord');
	var word = document.querySelector('.itemWord');
	var copy = document.querySelector('.itemCopy');
	document.addEventListener("selectionchange",
	function(e) {
		window.getSelection().selectAllChildren(word);
	},
	false);
});
</script>
</body>
</html>